home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13536 < prev    next >
Encoding:
Text File  |  1996-08-05  |  956 b   |  48 lines

  1. Path: ponder.csci.unt.edu!birdi
  2. From: birdi@ponder.csci.unt.edu (Arvinder S. Birdi )
  3. Newsgroups: comp.lang.c++
  4. Subject: too many field types in classes
  5. Date: 25 Mar 1996 21:51:05 GMT
  6. Organization: University of North Texas, Denton
  7. Distribution: usa
  8. Message-ID: <4j74g9$i58@hermes.acs.unt.edu>
  9. NNTP-Posting-Host: ponder.csci.unt.edu
  10.  
  11.  
  12. I am writing a db type application with classes that are used mostly
  13. to store data. (lots of classes simply have fields and set/gets)
  14.  
  15. Problem:
  16. there are many field types used in these classes and maintaining
  17. consistency becomes a problem. (ie was long used to store SSN in class
  18. x and double is used to store SSN in class y)
  19.  
  20. solution1:
  21. typedef the filed types and #include their definitions.
  22.  
  23. class dbtypes{
  24.     typedef long SSN;
  25.     typedef char[80] name;
  26. };
  27.  
  28.  
  29.  
  30. solution2:
  31. create each type as a tiny class;
  32.  
  33. class SSN{
  34.     long s;
  35. }
  36.  
  37. class Name {
  38.     char[80] n;
  39. }
  40.  
  41.  
  42. I'd like comments to the various solutions.
  43.  
  44. thanks
  45. -arvinder
  46.  
  47.  
  48.